package bukebianjihe;

import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

public class demo1 {
    public static void main(String[] args) {
          /*
            创建不可变的List集合
            "张三", "李四", "王五", "赵六"
        */

        //一旦创建完毕之后，是无法进行修改的，在下面的代码中，只能进行查询操作
        List<String> list = List.of("张三", "李四", "王五", "赵六");
        System.out.println("---------------------------");
        for (String s : list) {
            System.out.println(s);
        }
        System.out.println("---------------------------");
        Iterator <String> it=list.iterator();
        while (it.hasNext()) {
            System.out.println(it.next());

        }
        System.out.println("---------------------------");
        for (int i = 0; i < list.size(); i++) {
            String s = list.get(i);
            System.out.println(s);
        }
        System.out.println("---------------------------");
        list.forEach(( s) ->System.out.println(s));

    }
}
